/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.veterinarySystem.modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author 100101
 */
@Entity
@Table(name = "duenomascota")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DuenoMascota.findAll", query = "SELECT d FROM DuenoMascota d"),
    @NamedQuery(name = "DuenoMascota.findById", query = "SELECT d FROM DuenoMascota d WHERE d.id = :id"),
    @NamedQuery(name = "DuenoMascota.findByClave", query = "SELECT d FROM DuenoMascota d WHERE d.clave = :clave"),
    @NamedQuery(name = "DuenoMascota.findByNombre", query = "SELECT d FROM DuenoMascota d WHERE d.nombre = :nombre"),
    @NamedQuery(name = "DuenoMascota.findByApellidoPaterno", query = "SELECT d FROM DuenoMascota d WHERE d.apellidoPaterno = :apellidoPaterno"),
    @NamedQuery(name = "DuenoMascota.findByApellidoMaterno", query = "SELECT d FROM DuenoMascota d WHERE d.apellidoMaterno = :apellidoMaterno"),
    @NamedQuery(name = "DuenoMascota.findByTelefono", query = "SELECT d FROM DuenoMascota d WHERE d.telefono = :telefono"),
    @NamedQuery(name = "DuenoMascota.findByEmail", query = "SELECT d FROM DuenoMascota d WHERE d.email = :email"),
    @NamedQuery(name = "DuenoMascota.findByDomicilio", query = "SELECT d FROM DuenoMascota d WHERE d.domicilio = :domicilio"),
    @NamedQuery(name = "DuenoMascota.findDuplicity",query ="SELECT d FROM DuenoMascota d WHERE d.nombre = :nombre AND d.apellidoPaterno = :apellidoPaterno AND d.apellidoMaterno = :apellidoMaterno")
})
public class DuenoMascota implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "clave")
    private String clave;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "nombre")
    private String nombre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "apellidoPaterno")
    private String apellidoPaterno;
    @Size(max = 20)
    @Column(name = "apellidoMaterno")
    private String apellidoMaterno;
    @Column(name = "telefono")
    private Long telefono;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 25)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "domicilio")
    private String domicilio;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idDuenoMascota")
    private List<Mascota> mascotaList;

    public DuenoMascota() {
    }

    public DuenoMascota(Integer id) {
        this.id = id;
    }

    public DuenoMascota(Integer id, String clave, String nombre, String apellidoPaterno, String domicilio) {
        this.id = id;
        this.clave = clave;
        this.nombre = nombre;
        this.apellidoPaterno = apellidoPaterno;
        this.domicilio = domicilio;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getClave() {
        return clave;
    }

    public void setClave(String clave) {
        this.clave = clave;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getApellidoPaterno() {
        return apellidoPaterno;
    }

    public void setApellidoPaterno(String apellidoPaterno) {
        this.apellidoPaterno = apellidoPaterno;
    }

    public String getApellidoMaterno() {
        return apellidoMaterno;
    }

    public void setApellidoMaterno(String apellidoMaterno) {
        this.apellidoMaterno = apellidoMaterno;
    }

    public Long getTelefono() {
        return telefono;
    }

    public void setTelefono(Long telefono) {
        this.telefono = telefono;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getDomicilio() {
        return domicilio;
    }

    public void setDomicilio(String domicilio) {
        this.domicilio = domicilio;
    }

    @XmlTransient
    public List<Mascota> getMascotaList() {
        return mascotaList;
    }

    public void setMascotaList(List<Mascota> mascotaList) {
        this.mascotaList = mascotaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DuenoMascota)) {
            return false;
        }
        DuenoMascota other = (DuenoMascota) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return nombre+" "+apellidoPaterno;
    }
    
}
